<?php
include("header.php");
include("model/DB.php");
include("model/User.php");
include("model/Class.php");
include("function/teacher.login.php");
require_once("model/Course.php");

$class = Classes::getClassByTeacher($_SESSION['userid']);
$class_id = $class['id'];
$cs = Course::getCs($class_id);
$lesson = array();
foreach($cs as $c){
	 $no = $c['lesson'];
	 if($c['d1']!=0){
		 $course = Course::getCourseById($c['d1']);
		 $lesson[$no]['d1'] = $course['title'];	 
	 }
	 else{
		$lesson[$no]['d1'] = "None";
	 }
	 if($c['d2']!=0){
	 $course = Course::getCourseById($c['d2']);
	 $lesson[$no]['d2'] = $course['title'];
	 }
	 else{
		$lesson[$no]['d2'] = "None";
	 }
	 if($c['d3']!=0){
	 $course = Course::getCourseById($c['d3']);
	 $lesson[$no]['d3'] = $course['title'];	 
	 }
	 else{
		$lesson[$no]['d3'] = "None";
	 }	 
	 if($c['d4']!=0){
	 $course = Course::getCourseById($c['d4']);
	 $lesson[$no]['d4'] = $course['title'];
	 }
	 else{
		$lesson[$no]['d4'] = "None";
	 }
	 if($c['d5']!=0){
	 $course = Course::getCourseById($c['d5']);
	 $lesson[$no]['d5'] = $course['title'];
	 }
	 else{
		$lesson[$no]['d5'] = "None";
	 }	 
	 if($c['d6']!=0){
	 $course = Course::getCourseById($c['d6']);
	 $lesson[$no]['d6'] = $course['title'];
	 }
	 else{
		$lesson[$no]['d6'] = "None";
	 }	 
	 if($c['d7']!=0){
	 $course = Course::getCourseById($c['d7']);
	 $lesson[$no]['d7'] = $course['title'];
	 }
	 else{
		$lesson[$no]['d7'] = "None";
	 }	 
}
?>
<center>
<div id="admin_title">Teacher Panel</div>
<div id="admin_body">
	<div id="topbar">
		<a href="index.php">Home</a>|
		<a href="teacher.cal.php">Kid's Daliy Activity</a>|
		<a href="teacher.avatar.php">Kid's Overview & Avatar Management</a>|
		<a href="teacher.archive.php">Kid's Achivment</a>|
		<a href="teacher.msg.php">Message Box</a>|		
		<a href="logout.php">Log Out</a>
	</div>
<br>


<div id="char_indi">

</div>
<div id="stat_chart">
	<div id="chart_title">Curriculum Schedule</div>
	<div >
<table id="cs_t"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col">&nbsp;</th>
    <th scope="col">Mon</th>
    <th scope="col">Tus</th>
    <th scope="col">Wen</th>
    <th scope="col">Thr</th>
    <th scope="col">Fri</th>
    <th scope="col">Sat</th>
    <th scope="col">Sun</th>
  </tr>
  <tr>
    <th scope="row">9:00-9:45</th>
	<?php 

		for($i=1;$i<=7;$i++): 
		$tag = "d".$i;
	?>
    <td><?php echo $lesson[1][$tag] ?></td>
	<?php endfor; ?>
  </tr>
  <tr class="break">
    <th scope="row">9:45-10:15</th>
    <td colspan="7" >Break</td>
  </tr>
  <tr>
    <th scope="row">10:15-11:00</th>
	<?php 

		for($i=1;$i<=7;$i++): 
		$tag = "d".$i;
	?>
	<td><?php echo $lesson[2][$tag] ?></td>
   	<?php endfor; ?>
  </tr>
  <tr id="lunch">
   <th scope="row">11:00-15:00</th>
   <td colspan="8">Lunch & Siesta</td>
  </tr>
  <tr>
    <th scope="row">15:00-15:45</th>
	<?php 

		for($i=1;$i<=7;$i++): 
		$tag = "d".$i;
	?>
	<td><?php echo $lesson[3][$tag] ?></td>
   	<?php endfor; ?>
  </tr>
  <tr class="break">
    <th scope="row" >15:45-16:15</th>
    <td colspan="7">Break</td>
  </tr>
  <tr>
    <th scope="row">16:15-17:00</th>
	<?php 

		for($i=1;$i<=7;$i++): 
		$tag = "d".$i;
	?>
    <td><?php echo $lesson[4][$tag] ?></td>
	<?php endfor; ?>
  </tr>
</table>
	</div>
</div>

<center>